import request from '@/utils/request';

// 分页查询表单
export function listTable(params, data) {
  return request({
    url: '/web/bu/form/tableSetting/page',
    method: 'post',
    params,
    data,
  });
}

// 查询表单详情
export function getTable(id) {
  return request({
    url: `/web/bu/form/tableSetting/info/${id}`,
    method: 'get',
  });
}

// 删除表单
export function delTable(data) {
  return request({
    url: '/web/bu/form/tableSetting/delete',
    method: 'post',
    data,
  });
}

// 修改表单
export function updateTable(data) {
  return request({
    url: '/web/bu/form/tableSetting/edit',
    method: 'post',
    data,
  });
}

// 保存表单
export function addTable(data) {
  return request({
    url: '/web/bu/form/tableSetting/save',
    method: 'post',
    data,
  });
}

// 同步数据库
export function sycDbTable(data) {
  return request({
    url: '/web/bu/form/tableSetting/sycDbTable',
    method: 'post',
    data,
  });
}

// 查询未导入表列表
export function listDbTable(params, data) {
  return request({
    url: '/web/bu/form/tableSetting/meta/table/unImported/page',
    method: 'post',
    params,
    data,
  });
}

// 从数据库导入表到表单
export function importTable(data) {
  return request({
    url: '/web/bu/form/tableSetting/importTable',
    method: 'post',
    data,
  });
}

// 获取后端自动填充表达式字典
export function getAutoFillExpContent() {
  return request({
    url: '/web/bu/form/tableSetting/getAutoFillExpContent',
    method: 'get',
  });
}

// 查询字段类型
export function getFormColType() {
  return request({
    url: '/web/bu/form/tableSetting/getFormColType',
    method: 'get',
  });
}

// 检查列是否能修改
export function allowToModify(data) {
  return request({
    url: '/web/bu/form/tableSetting/col/canModify',
    method: 'post',
    data,
  });
}

// 查询数据源
export function listSource() {
  return request({
    url: '/web/db/datasource/dbDatasource/list',
    method: 'post',
    hmacReq: true,
    encryptReq: true,
    decryptRes: true,
  });
}
